[release/7.0] Fix RVA field alignment (#60) #61
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backporting #60 to the release/7.0 branch (which I created for this purpose, pointing at the commit currently referenced by the dotnet/linker 7.0 branch: https://github.com/dotnet/linker/tree/release/7.0/external).
This implements a cecil fix required to support the alignment requirements of the Roslyn
CreateSpan
support.Fixes dotnet/runtime#79477
Customer Impact
Soon (once we ship a Roslyn that supports the CreateSpan APIs introduced in 7.0), trimmed 7.0 apps using the latest Roslyn may start crashing if they use constant arrays of
long
orulong
that are cast toReadOnlySpan<T>
. The failure mode we have observed isArgumentException
duringCreateSpan
. The crash happens if the constant data representing the array happens to be misaligned after trimming (which is likely, because the 7.0 trimmer did not respect the new alignment requirements).Note that this hasn't actually been observed externally yet, but we anticipate that we will once the new Roslyn is shipped.
Testing
CreateSpan
support is being used in Use Roslyn support for RuntimeHelpers.CreateSpan (or field caching downlevel) runtime#79461, where we originally discovered the issue that this fixes. We will get validation of the same fix on 8.0 bits there.We might want to wait to service this until we have released the fix in an 8.0 preview to get extra validation in the wild.
Risk
Medium to high risk. This changes the alignment of the code section for all assemblies written by cecil on x64, and can also change the alignment of later sections, even for code which doesn't use
CreateSpan
helpers. The change is significant at the binary level, but we have no reason to believe that this will break anything downstream. If the binary change is problematic, we would expect to see catastrophic failures during the testing, but this was not the case. (An earlier incomplete fix did result in catastrophic failures, validating this expectation).